<html><head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<meta content="text/javascript" http-equiv="content-script-type">
<title>tango.net.cluster.QueuedCache</title>

<link rel="stylesheet" type="text/css" href="css/style.css">
<!--[if lt IE 7]><link rel="stylesheet" type="text/css" href="css/ie56hack.css"><![endif]-->
<script language="JavaScript" src="js/util.js" type="text/javascript"></script>
<script language="JavaScript" src="js/tree.js" type="text/javascript"></script>
<script language="JavaScript" src="js/explorer.js" type="text/javascript"></script>
<script>
function anchorFromTitle(title, path, ext) {
  var url = path + title + "." + ext;
  document.write("<a href='" + url + "'>" + title + "</a>");
  }
</script>
</head><body>
<div id="tabarea"></div><div id="explorerclient"></div>
<div id="content"><script>explorer.initialize("tango.net.cluster.QueuedCache");</script>
        <table class="content">
                <tr><td id="docbody"><h1><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461">tango.net.cluster.QueuedCache</a></h1>
                
<b>License:</b><br>
BSD style: see <a href="http://www.dsource.org/projects/tango/wiki/LibraryLicense">license.txt</a><br><br>
<b>Version:</b><br>
April 2004: Initial release<br><br>
<b>author:</b><br>Kris<br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>class <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L37">QueuedCache</a></span>
<script>explorer.outline.addDecl('QueuedCache');</script>(K, V) : ICache!(K, V);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">QueuedCache extends the basic cache type by adding a limit to
        the number of items contained at any given time. In addition,
        QueuedCache sorts the cache entries such that those entries
        frequently accessed are at the head of the queue, and those
        least frequently accessed are at the tail. When the queue
        becomes full, old entries are dropped from the tail and are
        reused to house new cache entries.</font><br><br>
<font color="black">This is great for keeping commonly accessed items around, while
        limiting the amount of memory used. Typically, the queue size
        would be set in the hundreds &#40;perhaps thousands&#41;.<br><br>        Note that key.init cannot be used as a valid key<br><br></font><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li><span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L55">this</a></span>
<script>explorer.outline.addDecl('this');</script>(uint <span class="funcparam">capacity</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Construct a cache with the specified maximum number of
                entries. Additions to the cache beyond this number will
                reuse the slot of the least-recently-referenced cache
                entry. The concurrency level indicates approximately how
                many threads will content for write access at one time.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L75">get</a></span>
<script>explorer.outline.addDecl('get');</script>(K <span class="funcparam">key</span>, inout V <span class="funcparam">value</span>); [synchronized]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Get the cache entry identified by the given key</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>V <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L93">get</a></span>
<script>explorer.outline.addDecl('get');</script>(K <span class="funcparam">key</span>); [synchronized]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Get the cache entry identified by the given key</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L118">put</a></span>
<script>explorer.outline.addDecl('put');</script>(K <span class="funcparam">key</span>, V <span class="funcparam">value</span>, Time <span class="funcparam">time</span> = Time.init); [synchronized]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Place an entry into the cache and associate it with the
                provided key. Note that there can be only one entry for
                any particular key. If two entries are added with the
                same key, the second effectively overwrites the first.</font><br><br>
<font color="black">An optional time value allows for testing whether an
                existing entry is newer than our provided one. Where
                the provided time value is lesser, the put&#40;&#41; operation
                will be abandoned and false is returned.<br><br>                Returns true if the cache was updated.<br><br></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>bool <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L140">put</a></span>
<script>explorer.outline.addDecl('put');</script>(K <span class="funcparam">peek</span>, K delegate() <span class="funcparam">key</span>, V delegate() <span class="funcparam">value</span>, Time <span class="funcparam">time</span> = Time.init); [synchronized]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Same as above, but being careful to avoid heap activity
                where the provided key and value are potentially aliased</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>V <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L164">remove</a></span>
<script>explorer.outline.addDecl('remove');</script>(K <span class="funcparam">key</span>, Time <span class="funcparam">time</span> = Time.max); [synchronized]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Remove &#40;and return&#41; the cache entry associated with the
                provided key. Returns null if there is no such entry.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>int <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L192">opApply</a></span>
<script>explorer.outline.addDecl('opApply');</script>(int delegate(inout K key, inout V value) <span class="funcparam">dg</span>); [synchronized]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Iterate over elements</font><br><br>
<font color="black">Note that this needs to be synchronized, and can therefore
                be very costly in terms of blocking other threads. Use with
                caution<br><br></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>QueuedEntry* <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L206">lookup</a></span>
<script>explorer.outline.addDecl('lookup');</script>(K <span class="funcparam">key</span>); [private, final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black"></font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>QueuedEntry* <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L219">deReference</a></span>
<script>explorer.outline.addDecl('deReference');</script>(QueuedEntry* <span class="funcparam">entry</span>); [private, final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Place a cache entry at the tail of the queue. This makes
                it the least-recently referenced.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>QueuedEntry* <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L241">reReference</a></span>
<script>explorer.outline.addDecl('reReference');</script>(QueuedEntry* <span class="funcparam">entry</span>); [private, final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Move a cache entry to the head of the queue. This makes
                it the most-recently referenced.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>QueuedEntry* <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L264">addEntry</a></span>
<script>explorer.outline.addDecl('addEntry');</script>(); [private, final]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Add an entry into the queue. If the queue is full, the
                least-recently-referenced entry is reused for the new
                addition.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>struct <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L285">QueuedEntry</a></span>
<script>explorer.outline.addDecl('QueuedEntry');</script>; [private, static]</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">A doubly-linked list entry, used as a wrapper for queued
                cache entries.</font><br><br>
<dl>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>QueuedEntry* <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L299">set</a></span>
<script>explorer.outline.addDecl('set');</script>(K <span class="funcparam">key</span>, V <span class="funcparam">value</span>, Time <span class="funcparam">time</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Set this entry with the given arguments.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>QueuedEntry* <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L314">prepend</a></span>
<script>explorer.outline.addDecl('prepend');</script>(QueuedEntry* <span class="funcparam">before</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Insert this entry into the linked-list just in front
                        of the given entry.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>QueuedEntry* <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L336">append</a></span>
<script>explorer.outline.addDecl('append');</script>(QueuedEntry* <span class="funcparam">after</span>);</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Add this entry into the linked-list just after the
                        given entry.</font><br><br></dd>
<script>explorer.outline.writeEnabled = true;</script>
<dt><span class="decl"><li>QueuedEntry* <span class="currsymbol"><a href="http://www.dsource.org/projects/tango/browser/trunk/tango/net/cluster/QueuedCache.d?rev=3461#L358">extract</a></span>
<script>explorer.outline.addDecl('extract');</script>();</li></span></dt>
<script>explorer.outline.writeEnabled = false;</script>
<dd>
<font color="black">Remove this entry from the linked-list. The previous
                        and next entries are patched together appropriately.</font><br><br></dd></dl></dd></dl></dd></dl></td></tr>
                <tr><td id="docfooter">
                        Copyright (c) 2004 Kris Bell. All rights reserved :: page rendered by CandyDoc. Generated by <a href="http://code.google.com/p/dil">dil</a> on Sun Jun  8 17:12:55 2008.
                </td></tr>
        </table>
</div>
<script></script>
</body></html>